package com.ruoyi.business.config;

import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class ALiBaBaIdCard {
    public String checkCard(String acctName,String account,String idCard,String phone) throws IOException {
        String host = "http://alysmrz.market.alicloudapi.com";
        String path = "/communication/personal/1882";
        String method = "POST";
        String appcode = "0234e4133bf143b081cadd69f5fb0b89";
        Map<String, String> headers = new HashMap<String, String>();
        //最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
        headers.put("Authorization", "APPCODE " + appcode);
        Map<String, String> querys = new HashMap<String, String>();
        /*querys.put("acct_name", "张若琳");
        querys.put("acct_pan", "6212263602097774996");
        querys.put("cert_id", "431028199304114022");
        querys.put("phone_num", "13427502451");*/
        querys.put("acct_name", acctName);
        querys.put("acct_pan", account);
        querys.put("cert_id", idCard);
        querys.put("phone_num", phone);
        HttpResponse response=null; 
        try {
            response = HttpUtils.doGet(host, path, method, headers, querys);
            //获取response的body
            //System.out.println(EntityUtils.toString(response.getEntity()));
        } catch (Exception e) {
            e.printStackTrace();
        }
        String entity = EntityUtils.toString(response.getEntity());
        return entity;
    }
}
